package com.bawei.shopping2.viewmodel

import androidx.lifecycle.ViewModel
import com.bawei.shopping2.entity.BannerEntity
import com.bawei.shopping2.entity.CategoryEntity
import com.bawei.shopping2.entity.GoodsEntity
import com.bawei.shopping2.http.ApiResponse
import com.bawei.shopping2.repository.DetailRepository
import com.bawei.shopping2.repository.MainRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

//注意：依赖注入到viewModel
@HiltViewModel
class DetailViewModel @Inject constructor(private var detailRepository: DetailRepository ):ViewModel() {
    //商品详情
    suspend fun goodsDetail( goods_id:Int):ApiResponse<GoodsEntity>{
        return detailRepository.goodsDetail(goods_id)
    }
    //添加购物车
    suspend fun addCar( requestBody: RequestBody):ApiResponse<String>{
        return detailRepository.addCar(requestBody)
    }
}